"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mysql = require("mysql");
const Logger_1 = require("./Logger");
class MySqlUtil {
    static init() {
        if (this.isInited) {
            return;
        }
        this.isInited = true;
        let config = {
            "host": this.MySql_Host,
            "user": this.MySql_User,
            "password": this.MySql_Pass,
            "database": this.Mysql_database
        };
        this.connection = mysql.createConnection(config);
        this.connection.connect();
        // let test:string = "SELECT * FROM users;";
        // let test:string = "INSERT INTO users values(null, 100003, 'test3', 'nickname3');";
        // this.executeSql(test);
    }
    static executeSql(sql, callback) {
        this.init();
        this.connection.query(sql, (err, result) => {
            if (err) {
                Logger_1.Logger.warn("executeSql error ", err.message);
                callback(false, err);
                return;
            }
            // Logger.log("executeSql res=", result);
            callback(true, result);
        });
        // this.connection.end();
    }
}
exports.MySqlUtil = MySqlUtil;
MySqlUtil.MySql_Host = "127.0.0.1"; //
MySqlUtil.MySql_Port = 3306; //
MySqlUtil.MySql_User = "root";
MySqlUtil.MySql_Pass = "666666";
MySqlUtil.Mysql_database = "haogame";
MySqlUtil.isInited = false;
